package org.anachronos.jeep.probec.model;

import java.util.ArrayList;
import java.util.List;

import javax.lang.model.element.TypeElement;

public class ProbeType {
	private final String simpleName;
	private final String pkg;
	private final List<ProbeMethod> methods = new ArrayList<ProbeMethod>();
	private TypeElement typeElement;
	private ProbeEnablement enablement;
	
	public ProbeType(final String simpleName, final String pkg) {
		this.simpleName = simpleName;
		this.pkg = pkg;
	}

	public static ProbeType create(final TypeElement typeElement) {
		final String simpleName = typeElement.getSimpleName().toString();
		final String qualifiedName = typeElement.getQualifiedName().toString();
		final String pkg = qualifiedName.substring(0, 
				qualifiedName.length() - 1 - simpleName.length());
		final ProbeType probeType = new ProbeType(simpleName, pkg);
		probeType.typeElement = typeElement;
		return probeType;
	}
	
	public ProbeEnablement getEnablement() {
		return enablement;
	}
	
	
	public void setEnablement(final ProbeEnablement enablement) {
		this.enablement = enablement;
	}

	public TypeElement getTypeElement() {
		return typeElement;
	}
	
	public String getGenFullName() {
		return pkg.concat(".").concat(getGenClass());
	}
	
	public String getPackage() {
		return pkg;
	}
	
	public String getSimpleName() {
		return simpleName;
	}

	public String getGenClass() {
		return simpleName.concat("ClassAdapter");
	}
	
	public List<ProbeMethod> getMethods() {
		return methods;
	}
	
	public void add(final ProbeMethod method) {
		methods.add(method);
	}

	@Override
	public String toString() {
		return "ProbeType [simpleName=" + simpleName + ", methods=" + methods
				+ "]";
	}
}
